<?php

class DefaultController extends Controller
{
	public $layout='//layouts/main';
	public function init()
	{
			Yii::app()->theme = 'orange';
			parent::init();
	}
	public function actionIndex($alias=null)
	{
		
		$key = $alias;
		$keyCategories = "";
		$aliasKey = $key;
		$arrKey = explode("/",$key);
		if(!empty($arrKey)){
			foreach($arrKey as $key=>$value){
				if($key== count($arrKey)-1){
					$keyCategories = $value;
				}
			}
		}
		$alias = $keyCategories;
		$gadget = Gadget::model()->getBizFromAlias($alias);
		if(empty($gadget)){
			$this->redirect(array('/dashboard'));
		}
		
		$this->render('index',array(
			'gadget'=>$gadget,
			'condition'=>Gadgetcondition::model()->findAll()
		));
	}
}